home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <netdb.h>
- #include "inet.h"
-
- #define MAXBUFSIZ 500000
-
- char buf[MAXBUFSIZ];
-
- main()
- {
-
- int writer;
- int cc;
- int fd;
- fd_set fds;
- FD_ZERO(&fds);
-
- fd = initport(PORT_NUMBER(2000),SERVER,SOCK_STREAM);
- if (fd < 0) {
- fprintf(stderr,"initport() = %d\n",fd);
- exit(-1);
- }
-
- while (TRUE) {
- writer = select_server_stream(fd,&fds);
- /* cc = sized_read(writer,buf,MAXBUFSIZ);*/
- cc = recv(writer,buf,MAXBUFSIZ,0);
- if (cc <= 0) {
- printf("%d: EOF\n",writer);
- close(writer);
- continue;
- }
- printf("%d: %d bytes received\n",writer,cc);
- /* if (cc == 1) cc = sized_write(writer,"1 char",6);*/
- if (cc == 1) cc = send(writer,"1 char",6,0);
- }
- }
-